import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DomainFilterToolBar extends StatelessWidget {
  const DomainFilterToolBar({
    super.key,
    required this.filterCount,
    required this.onCheck,
    required this.onReset,
    required this.onConfirm,
  });

  // 筛选条件数量
  final int filterCount;
  // 事件
  // 查看
  final Function() onCheck;
  // 重置
  final Function() onReset;
  // 确定
  final Function() onConfirm;

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
      width: double.infinity,
      height: 100.h + MediaQuery.of(context).padding.bottom,
      child: SafeArea(
        child: Column(
          children: [
            SizedBox(
              width: double.infinity,
              height: 40.h,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  if (filterCount == 0)
                    Text(
                      '您还没有添加条件哦！',
                      style: TextStyle(
                        fontSize: 14.sp,
                        fontWeight: FontWeight.bold,
                        color: Colors.blue,
                      ),
                    )
                  else
                    Row(
                      children: [
                        Text('已添加'),
                        Container(
                          width: 20.h,
                          height: 20.h,
                          decoration: BoxDecoration(
                            color: Colors.red[400],
                            shape: BoxShape.circle,
                          ),
                          child: Center(
                            child: Text(
                              '$filterCount',
                              style: TextStyle(
                                color: Colors.white,
                                fontSize: 12.sp,
                              ),
                            ),
                          ),
                        ),
                        Text('个条件'),
                      ],
                    ),
                  Spacer(),
                  TextButton(
                    onPressed: onCheck,
                    child: Row(
                      children: const [
                        Text('点击查看', style: TextStyle(color: Colors.black87)),
                        Icon(Icons.chevron_right, color: Colors.black54),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            SizedBox(
              width: double.infinity,
              height: 44.h,
              child: Row(
                children: [
                  Expanded(
                    child: ElevatedButton(
                      onPressed: onReset,
                      style: ElevatedButton.styleFrom(
                        backgroundColor: Colors.grey[200],
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(6),
                        ),
                      ),
                      child: const Text(
                        '重置条件',
                        style: TextStyle(color: Colors.black54),
                      ),
                    ),
                  ),
                  SizedBox(width: 16.w),
                  Expanded(
                    child: ElevatedButton(
                      onPressed: onConfirm,
                      style: ElevatedButton.styleFrom(
                        backgroundColor: Colors.red[400],
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(6),
                        ),
                      ),
                      child: const Text(
                        '立即筛选',
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
